import React, { useEffect, useRef } from 'react';
import { connect, withRouter } from 'umi';
import { INIT_WEBSCENE } from '../../constants/action-types';
// 头部组件
import Header from '@/components/content/Header';
import { useEffectOnce } from 'react-use';
import styles from '..//page_common.less';
import ProjPage from '@/components/content/projectPage';
import ProjectList from '@/components/content/projectList';
import Compareview from '@/components/content/projectPage/Compareview';
import './index.less';
import cls from 'classnames';
const IndexPage = props => {
  const viewDiv = useRef(null);

  // 初始化地图
  useEffectOnce(() => {
    if (screen.width <= 1440) {
      const html = document.getElementsByTagName('html')[0];
      html.style.zoom = '74%';
    }
    //  初始化地图，加载底图
    props.dispatch({
      type: INIT_WEBSCENE,
      payload: {
        container: viewDiv.current,
      },
    });

    // 初始化图层列表 并渲染图层
    // props.dispatch({ type: 'bimmodel/initAllBimModels' });
  });

  return (
    <div className={cls(styles.wrapper, 'project-page')}>
      <Header />
      <ProjectList />
      <div className={styles.viewContainer}>
        <div ref={viewDiv} className={cls(styles.viewDiv, 'proj-view')}></div>
        <Compareview></Compareview>
      </div>
      <ProjPage />
    </div>
  );
};

export default withRouter(
  connect(({ app }) => {
    return {
      curProjId: app.curProjId,
    };
  })(IndexPage),
);
